# Use an official Python runtime as a parent image
FROM python:3.6-slim

# Copy the current directory contents into the container at /app
ADD . /app

# Set the working directory to /app
WORKDIR /app

RUN mv /etc/apt/sources.list /etc/apt/sources.list.bak && \
    echo "deb http://mirrors.163.com/debian/ jessie main non-free contrib" >/etc/apt/sources.list && \
    echo "deb http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie main non-free contrib" >>/etc/apt/sources.list && \
    echo "deb-src http://mirrors.163.com/debian/ jessie-proposed-updates main non-free contrib" >>/etc/apt/sources.list
RUN apt-get update
RUN apt-get install libfontconfig --assume-yes
RUN mv /app/vendor/phantomjs /usr/local/bin/phantomjs

RUN phantomjs

# Install any needed packages specified in requirements.txt
RUN pip install --trusted-host pypi.douban.com/simple -i https://pypi.douban.com/simple -r requirements.txt 

# Make port 80 available to the world outside this container
EXPOSE 5000

# Define environment variable
ENV NAME World

# Run app.py when the container launches
RUN ["python", "spider/crawl.py"]

CMD ["python", "analy-estate.py"]
